package com.laoba.guligateway.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.reactive.CorsWebFilter;
import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;

/**
 * 古丽歌珥配置
 *
 * @author 老八
 * @date 2023/04/10
 */
@Configuration
public class GuliCorsConfiguration {
    /**
     * 配置跨域
     * @return
     */
    @Bean
    public CorsWebFilter corsWebFilter()
    {
        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
        CorsConfiguration confign = new CorsConfiguration();
        confign.addAllowedHeader("*");
        confign.addAllowedMethod("*");
        confign.addAllowedOrigin("*");
        confign.setAllowCredentials(true);
        source.registerCorsConfiguration("/**",confign);
        return new CorsWebFilter(source);
    }
}
